--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 96dddf1b3a0328f22b59ac7d4fcc8193d9884a44
Parents : c426c93
Author : Mark Qvist <mark@unsigned.io>
Date : 2024-12-23T12:36:53+01:00
Added handling of corrupted transient ID cache files
Changes
Diff
diff --git a/LXMF/LXMRouter.py b/LXMF/LXMRouter.py
index 743cfa8..fa168ef 100644
--- a/LXMF/LXMRouter.py
+++ b/LXMF/LXMRouter.py
@@ -143,19 +143,31 @@ class LXMRouter:
if os.path.isfile(self.storagepath+"/local_deliveries"):
locally_delivered_file = open(self.storagepath+"/local_deliveries", "rb")
data = locally_delivered_file.read()
- self.locally_delivered_transient_ids = msgpack.unpackb(data)
locally_delivered_file.close()
+ self.locally_delivered_transient_ids = msgpack.unpackb(data)
+ except Exception as e:
+ RNS.log("Could not load locally delivered message ID cache from storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ self.locally_delivered_transient_ids = {}
+
+ try:
if os.path.isfile(self.storagepath+"/locally_processed"):
locally_processed_file = open(self.storagepath+"/locally_processed", "rb")
data = locally_processed_file.read()
- self.locally_processed_transient_ids = msgpack.unpackb(data)
locally_processed_file.close()
-
+ self.locally_processed_transient_ids = msgpack.unpackb(data)
+
+ except Exception as e:
+ RNS.log("Could not load locally processed message ID cache from storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ self.locally_processed_transient_ids = {}
+
+ try:
self.clean_transient_id_caches()
except Exception as e:
- RNS.log("Could not load locally delivered message ID cache from storage. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ RNS.log("Could not clean transient ID caches. The contained exception was : "+str(e), RNS.LOG_ERROR)
+ self.locally_delivered_transient_ids = {}
+ self.locally_processed_transient_ids = {}
try:
if os.path.isfile(self.storagepath+"/outbound_stamp_costs"):
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────